<script type="text/tpl">
	var time = 100;
	var i = 1;
	setInterval(function(){
		i ++;
		console.log(i);
	},time);//time只读一次，不可更改
	time = 10;
</script>

<script type="text/tpl">
	var firstTime = new Date().getTime();//获取当前时间戳

	setInterval(function(){//判断定时器误差
		var lastTime = new Date().getTime();//再获取一个时间
		console.log(lastTime - firstTime);//打印执行定时器的时差
		firstTime = lastTime;//把后面时间值赋给开始时间
	},1000)
</script>

<script type="text/javascript">
	var i = 0;
	var time1 = setInterval(function(){
		console.log(i ++);
		if(i > 5){
			clearInterval(time1);
		}
	},1000);//返回1作为定时器的唯一标识
	clearInterval(time1);
	var time2 = setInterval(function(){},100);
	clearInterval(time2);//清除clear的唯一标识

	var time2 = setTimeout(function(){//和setInterval返回标识不会一样
		console.log('a');
	},100);//推迟一定时间执行一次
</script>

<!DOCTYPE html>
<html>
<head>
	<title></title>
	<style type="text/css">
		input{
			border: 1px black solid;
			text-align: right;
			font-size : 20px;
		}
	</style>
</head>
<body>
	minutes : <input type="" name="" value="0">
	second : <input type="" name="" value="0">

设置一个三分钟计时器
	<script type="text/javascript">
		var minNode = document.getElementsByTagName('input')[0];
		var secNode = document.getElementsByTagName('input')[1];
		var sec = 0,
			min = 0;
		var timer = setInterval(function(){
			sec ++;
			if(sec == 60){
				min ++;
				sec = 0;
			}
			minNode.value = min;
			secNode.value = sec;
			if(min == 3){
				clearInterval(timer)
			}
		},100)
	</script>
</body>
</html>